/**
 * 
 */
package com.greenhouse.business.common.wraning;

import java.util.Map;

import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlExpression;
import org.apache.commons.jexl3.MapContext;

/**
 *
 * @版权 : Copyright (c) 2020 儒安物联技术研发中心
 * @author: 雷扬
 * @E-mail: leiyang@runaiot.com
 * @版本: 1.0
 * @创建日期: 2021-5-9 13:15:27
 * @ClassName Evaluator
 * @类描述-Description:  TODO(这里用一句话描述这个方法的作用)
 * @修改记录:
 * @版本: 1.0
 */

public class Evaluator {

	private JexlEngine jexl;

	public Evaluator() {
		this.jexl = new JexlBuilder().create();
	}

	public Object execute(JexlExpression expression, Map<String, Object> map) {
		JexlContext jc = new MapContext(map);
		return expression.evaluate(jc);
	}

	public JexlExpression compile(String expression) {
		return jexl.createExpression(expression);
	}
}
